﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI.WebControls;
using System.Data;

namespace DangKyOnline.QuanTriGhiDanh.Data
{
    public class ClsHeThong
    {
        public static void LoadNam(DropDownList dro)
        {
            dro.Items.Clear();
            dro.Items.Add(new ListItem("---Chọn---",""));
            for (int i = 1900; i <= DateTime.Now.Year; i++)
			{
			    dro.Items.Add(new ListItem (i.ToString(),i.ToString()));
			}
            dro.SelectedValue="";
        }
        public static void LoadThang(DropDownList dro)
        {
            dro.Items.Clear();
            dro.Items.Add(new ListItem("---Chọn---",""));
            for (int i = 1; i <= 12; i++)
			{
			    dro.Items.Add(new ListItem (i.ToString(),i.ToString()));
			}
            dro.SelectedValue=DateTime.Now.Month.ToString();
        }
        public static void LoadNgay(DropDownList dro)
        {
            dro.Items.Clear();
            dro.Items.Add(new ListItem("---Chọn---", ""));
            for (int i = 1; i <= 31; i++)
            {
                dro.Items.Add(new ListItem(i.ToString(), i.ToString()));
            }
            dro.SelectedValue = DateTime.Now.Day.ToString();
        }
        public static void LoadDanhMuc(string ValueField, string DisplayField, DataTable dt, DropDownList dro)
        {
            try 
	        {
                dro.Items.Add(new ListItem("---Chọn---", ""));
                if (dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        dro.Items.Add(new ListItem(row[DisplayField].ToString(), row[ValueField].ToString()));
                    }
                }
                dro.SelectedValue = "";
	        }
	        catch (Exception ex)
	        {
		       
	        }
        }
    }
}